Micron Document
baubs git

Node / mirrors / respira / files / src / platform / index.ts

Displaying Raw • Download

src/platform/index.ts fix/pattern-rendering-and-coordinate-bugs (abf7b9a6) Text, 1.05 KB

import type { IStorageService } from './interfaces/IStorageService';
import type { IFileService } from './interfaces/IFileService';
import { BrowserStorageService } from './browser/BrowserStorageService';
import { BrowserFileService } from './browser/BrowserFileService';
import { ElectronStorageService } from './electron/ElectronStorageService';
import { ElectronFileService } from './electron/ElectronFileService';

/**
* Detect if running in Electron
*/
export function isElectron(): boolean {
return !!(typeof window !== 'undefined' && window.process && window.process.type === 'renderer');
}

/**
* Create storage service based on platform
*/
export function createStorageService(): IStorageService {
if (isElectron()) {
return new ElectronStorageService();
} else {
return new BrowserStorageService();
}
}

/**
* Create file service based on platform
*/
export function createFileService(): IFileService {
if (isElectron()) {
return new ElectronFileService();
} else {
return new BrowserFileService();
}
}

Served by rngit 1.3.3 - Generated in 0.03s